import 'package:flutter/material.dart';

import 'MyGestureDetector.dart';

class TitleBarWidget extends StatelessWidget {
  final String title;
  final List<Widget>? rightWidget;

  const TitleBarWidget({super.key, required this.title, this.rightWidget = const []});

  @override
  Widget build(BuildContext context) {
    return Stack(alignment: Alignment.centerLeft, children: [
      Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [Text(title, style: const TextStyle(color: Colors.black, fontSize: 18))]),
      Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
        MyGestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () => Navigator.of(context).pop(),
            child: const Row(mainAxisSize: MainAxisSize.min, children: [
              Padding(padding: EdgeInsets.all(10), child: Icon(color: Colors.black, Icons.arrow_back_ios_outlined))
            ])),
        //右边的按钮
        Row(mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, children: rightWidget!)
      ])
    ]);
  }
}
